<script>
	export default {
		onLaunch: function() {
			const _this = this;
			if(!localStorage.token){
				return;
			}
			setTimeout(()=>{
				_this.$api.getUserInfo().then((res)=>{
					if(res.data.returnCode == 200){
						const data = res.data.result
						const portrait = data.avatarAddress || 'http://jlm-file.oss-cn-hangzhou.aliyuncs.com/jlm-product/image/portrait/2020/11/9472ab92fe90400fbee424c2d6b02fb0.png'
						_this.$api.IMgetUserToken({id:data.id,name:data.realName,portrait:portrait}).then((responest)=>{
							const token = responest.data.result.token
							localStorage.setItem('IMTOKEN',token)
							_this.$im.connect({token:localStorage.IMTOKEN}).then(function(user) {
								console.log('链接成功: ', user)
								localStorage.setItem('IMCOEDID',user.id)
							}).catch(function(error) {
								console.log('链接失败: ', error.code, error.msg);
							});
						})
					}  
				})
			},1000)
			console.log('App Launch')  
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			//隐藏掉头部导航
			navTitle(){
				let navTitle = document.getElementsByTagName('uni-page-head');
				navTitle[0].style.display = 'none'
			}
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	/*每个页面公共css */
	.uni-input-placeholder {
		color: #999999;
		font-size: 28upx;
	}
	/deep/ .new .u-model__footer__button {
		border-right: 1upx solid #E7E7E7;
	}
	
	/deep/ .new .u-border-top:after {
		border-top-width: 0;
		border-top: 4upx solid #E7E7E7;
	}
</style>
